unit GMedParkPlotis;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, GForm, cxGraphics, cxPropertiesStore, dxBarExtItems, dxBar,
  cxClasses, ActnList, dxStatusBar, cxControls, cxPC, cxStyles, cxCustomData,
  cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData, cxGridLevel,
  cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxGridCustomView,
  cxGrid, cxNavigator, cxDBNavigator, cxContainer, cxGroupBox, cxCalc;

type
  TfMedParkPlotis = class(TGamaForm)
    tsSarasas: TcxTabSheet;
    dbgSarasas: TcxGrid;
    dbgSarasasDBTableView: TcxGridDBTableView;
    dbgSarasasLevel1: TcxGridLevel;
    cxGroupBox1: TcxGroupBox;
    dbnNav: TcxDBNavigator;
    dbgSarasasDBTableViewplotis: TcxGridDBColumn;
    procedure FormShow(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }
    procedure LentelesOn;
    procedure LentelesOff;
    //
    procedure MainBeforeInserOrEdit(DataSet: TDataSet);
    procedure MainBeforePost(DataSet: TDataSet);
    procedure MainAfterPostOrDelete(DataSet: TDataSet);
    procedure MainAfterPostOrDeleteOrCancel(DataSet: TDataSet);
    procedure MainPostError(DataSet: TDataSet;
                E: EDatabaseError; var Action: TDataAction);
    procedure MainNewRecord(DataSet: TDataSet);
  public
    { Public declarations }
    procedure RefreshTables; override;
  end;

var
  fMedParkPlotis: TfMedParkPlotis;

implementation

{$R *.dfm}

uses
  bendri, med_dm, Tools;

procedure TfMedParkPlotis.LentelesOn;
begin
  with dmMed do begin
    tbMedParkPlotis.BeforeInsert  := self.MainBeforeInserOrEdit;
    tbMedParkPlotis.BeforeEdit    := self.MainBeforeInserOrEdit;
    tbMedParkPlotis.BeforePost    := self.MainBeforePost;
    tbMedParkPlotis.AfterPost     := self.MainAfterPostOrDelete;
    tbMedParkPlotis.AfterDelete   := self.MainAfterPostOrDelete;
    tbMedParkPlotis.AfterCancel   := self.MainAfterPostOrDeleteOrCancel;
    //tbMedParkPlotis.OnPostError   := self.MainPostError;
    tbMedParkPlotis.OnNewRecord   := self.MainNewRecord;
  end;
end;

procedure TfMedParkPlotis.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  inherited;
  LentelesOff;
end;

procedure TfMedParkPlotis.FormShow(Sender: TObject);
begin
  inherited;
  LentelesOn;
end;

procedure TfMedParkPlotis.LentelesOff;
begin
  with dmMed do begin
    tbMedParkPlotis.BeforeInsert  := nil;
    tbMedParkPlotis.BeforeEdit    := nil;
    tbMedParkPlotis.BeforePost    := nil;
    tbMedParkPlotis.AfterPost     := nil;
    tbMedParkPlotis.AfterDelete   := nil;
    tbMedParkPlotis.AfterCancel   := nil;
    //tbMedParkPlotis.OnPostError   := nil;
    tbMedParkPlotis.OnNewRecord   := nil;
  end;
end;

procedure TfMedParkPlotis.MainBeforePost(DataSet: TDataSet);
begin
  //MessageText := '';
  //dmBendras.RandomIDBeforePost(DataSet);
end;

procedure TfMedParkPlotis.MainPostError(DataSet: TDataSet;
                E: EDatabaseError; var Action: TDataAction);
begin
  //dmBendras.RandomIDPostError(DataSet, E, Action);
end;

procedure TfMedParkPlotis.MainNewRecord(DataSet: TDataSet);
begin
  //
end;

procedure TfMedParkPlotis.MainAfterPostOrDelete(DataSet: TDataSet);
begin
  dmBendras.ApplyUpdatesAfterPostOrDelete(DataSet);
  MainAfterPostOrDeleteOrCancel(DataSet);
  bRefreshTables := true;
end;

procedure TfMedParkPlotis.MainAfterPostOrDeleteOrCancel(DataSet: TDataSet);
begin
  SetControlsEditColor( DataSet, GamaPageControl, false );
end;

procedure TfMedParkPlotis.MainBeforeInserOrEdit(DataSet: TDataSet);
begin
  SetControlsEditColor( DataSet, GamaPageControl, true);
end;

procedure TfMedParkPlotis.RefreshTables;
begin
  if bRefreshTables then begin
    bRefreshTables := false;
    //dmAlga.tbIssilavLookup.Refresh;
  end
end;

end.
